package com.example.zsfinacialmanage.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.example.zsfinacialmanage.R;
import com.example.zsfinacialmanage.bean.IncomeBran;
import com.example.zsfinacialmanage.other.InManageActivity;
import java.util.List;
public class IncomeAdapter extends RecyclerView.Adapter<IncomeAdapter.ViewHolder> {
    Context mcontext;
    List<IncomeBran> arr2;
    public IncomeAdapter(Context mcontext, List<IncomeBran>arr2) {
        this.mcontext = mcontext;
        this.arr2=arr2;
    }
    @Override
    public IncomeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mcontext).inflate(R.layout.recy_item_in, parent, false);
        ViewHolder mholder=new ViewHolder(view);
        return mholder;
    }
    @Override
    public void onBindViewHolder(IncomeAdapter.ViewHolder mholder, int position) {
        //IncomeBran incomeBran=arr2.get(position);
        final IncomeBran incomeBran=arr2.get(position);
        mholder.item_payer.setText("收款-来自"+incomeBran.getPayer());
        mholder.item_type.setText(incomeBran.getType());
        mholder.item_time.setText(incomeBran.getTime());
        mholder.item_remark.setText(incomeBran.getRemark());
        mholder.item_money.setText(incomeBran.getMoney()+"");
        mholder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toast.makeText(mcontext,"点击了"+incomeBran.getPayer(),Toast.LENGTH_SHORT).show();
                Intent intent=new Intent(mcontext, InManageActivity.class);
                intent.putExtra("seri", incomeBran);
                mcontext.startActivity(intent);
                ((Activity)mcontext).finish();
            }
        });
    }
    @Override
    public int getItemCount() {
        return arr2.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView item_payer,item_type,item_time,item_remark,item_money;
        public ViewHolder(View view) {
            super(view);
            item_payer=view.findViewById(R.id.item_payer_in);
            item_type=view.findViewById(R.id.item_type_in);
            item_time=view.findViewById(R.id.item_time_in);
            item_remark=view.findViewById(R.id.item_remark_in);
            item_money=view.findViewById(R.id.item_money_in);
        }
    }
}